﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WindowsFormsModel.BusinessObjects;
using WindowsFormsModel.ActionServiceReference;

namespace WindowsFormsModel.DataTransferObjectMapper
{
    internal static class Mapper
    {
        internal static UserGroupModel FromDataTransferObject(UserGroup userGroup)
        {
            return new UserGroupModel
            {
                UserGroupID = userGroup.UserGroupID,
                UserGroupName = userGroup.UserGroupName,
                Image = userGroup.Image,
                RestaurantID = userGroup.RestaurantID,
                CreateBy = userGroup.CreateBy,
                CreateDate = userGroup.CreateDate,
                ModifiedBy = userGroup.ModifiedBy,
                ModifiedDate = userGroup.ModifiedDate,
                Description = userGroup.Description,
                IsActive = userGroup.IsActive,
            };
        }

        internal static RestaurantModel FromDataTransferObject(Restaurant restaurant)
        {
            return new RestaurantModel
            {
                RestaurantID = restaurant.RestaurantID,
                RestaurantCode = restaurant.RestaurantCode,
                RestaurantName = restaurant.RestaurantName,
                Address = restaurant.Address,
                PhoneNumber = restaurant.PhoneNumber,
                Fax = restaurant.Fax,
                Email = restaurant.Email,
                Website = restaurant.Website,
                TaxCode = restaurant.TaxCode,
                IsActive = restaurant.IsActive,
                IsAgencies = restaurant.IsAgencies,
                Description = restaurant.Description
            };
        }

        internal static AccountingObjectCategoryModel FromDataTransferObject(AccountingObjectCategory accountingObjectCategory)
        {
            return new AccountingObjectCategoryModel
            {
                AccountingObjectCategoryID = accountingObjectCategory.AccountingObjectCategoryID,
                AccountingObjectCategoryCode = accountingObjectCategory.AccountingObjectCategoryCode,
                AccountingObjectCategoryName = accountingObjectCategory.AccountingObjectCategoryName,
                ParentID = accountingObjectCategory.ParentID,
                IsParent = accountingObjectCategory.IsParent,
                IsCustomer = accountingObjectCategory.IsCustomer,
                IsVendor = accountingObjectCategory.IsVendor,
                IsEmployee = accountingObjectCategory.IsEmployee,
                RestaurantID = accountingObjectCategory.RestaurantID,
                Description = accountingObjectCategory.Description,
                IsActive = accountingObjectCategory.IsActive
            };
        }

        internal static InventoryItemCategoryModel FromDataTransferObject(InventoryItemCategory inventoryItemCategory)
        {
            return new InventoryItemCategoryModel
            {
                InventoryCategoryID = inventoryItemCategory.InventoryCategoryID,
                InventoryCategoryCode = inventoryItemCategory.InventoryCategoryCode,
                InventoryCategoryName = inventoryItemCategory.InventoryCategoryName,
                ParentID = inventoryItemCategory.ParentID,
                IsParent = inventoryItemCategory.IsParent,
                RestaurantID = inventoryItemCategory.RestaurantID,
                IsMaterial = inventoryItemCategory.IsMaterial,
                Description = inventoryItemCategory.Description,
                IsActive = inventoryItemCategory.IsActive
            };
        }

        internal static RestaurantMenuCategoryModel FromDataTransferObject(RestaurantMenuCategory restaurantMenuCategory)
        {
            return new RestaurantMenuCategoryModel
            {
                MenuCategoryID = restaurantMenuCategory.MenuCategoryID,
                MenuCategoryCode = restaurantMenuCategory.MenuCategoryCode,
                MenuCategoryName = restaurantMenuCategory.MenuCategoryName,
                RestaurantID = restaurantMenuCategory.RestaurantID,
                IsParent = restaurantMenuCategory.IsParent,
                ParentID = restaurantMenuCategory.ParentID,
                Description = restaurantMenuCategory.Description,
                IsActive = restaurantMenuCategory.IsActive
            };
        }

        internal static CountryRegionModel FromDataTransferObject(CountryRegion countryRegion)
        {
            return new CountryRegionModel
            {
                CountryRegionCode = countryRegion.CountryRegionCode,
                CountryRegionName = countryRegion.CountryRegionName,
                CreateDate = countryRegion.CreateDate,
                ModifiedDate = countryRegion.ModifiedDate,
                Description = countryRegion.Description,
                IsActive = countryRegion.IsActive
            };
        }

        internal static TimeSheetSignModel FromDataTransferObject(TimeSheetSign timeSheetSign)
        {
            return new TimeSheetSignModel
            {
                TimeSheetSignID = timeSheetSign.TimeSheetSignID,
                TimeSheetSignCode = timeSheetSign.TimeSheetSignCode,
                TimeSheetSignName = timeSheetSign.TimeSheetSignName,
                SalaryRate = timeSheetSign.SalaryRate,
                Description = timeSheetSign.Description,
                IsActive = timeSheetSign.IsActive
            };
        }

        internal static ShipMethodModel FromDataTransferObject(ShipMethod shipMethod)
        {
            return new ShipMethodModel
            {
                ShipMethodID = shipMethod.ShipMethodID,
                ShipCode = shipMethod.ShipCode,
                ShipName = shipMethod.ShipName,
                Description = shipMethod.Description,
                IsActive = shipMethod.IsActive
            };
        }

        internal static AutoIDModel FromDataTransferObject(AutoID autoId)
        {
            return new AutoIDModel
            {
                AutoId = autoId.AutoId,
                RefTypeID = autoId.RefTypeID,
                RefTypeName = autoId.RefTypeName,
                Prefix = autoId.Prefix,
                Value = autoId.Value,
                LengthOfValue = autoId.LengthOfValue,
                Suffix = autoId.Suffix,
                RestaurantID = autoId.RestaurantID,
            };
        }

        internal static DistrictModel FromDataTransferObject(District district)
        {
            return new DistrictModel
            {
                DistrictCode = district.DistrictCode,
                DistrictName = district.DistrictName,
                CreateDate = district.CreateDate,
                ModifiedDate = district.ModifiedDate,
                Description = district.Description,
                IsActive = district.IsActive
            };
        }

        internal static CurrencyModel FromDataTransferObject(Currency currency)
        {
            return new CurrencyModel
            {
                CurrencyID = currency.CurrencyID,
                CurrencyCode = currency.CurrencyCode,
                CurrencyName = currency.CurrencyName,
                Description = currency.Description,
                IsActive = currency.IsActive
            };
        }

        internal static DepartmentModel FromDataTransferObject(Department department)
        {
            return new DepartmentModel
            {
                DepartmentID = department.DepartmentID,
                DepartmentCode = department.DepartmentCode,
                DepartmentName = department.DepartmentName,
                Description = department.Description,
                IsActive = department.IsActive,
                IsParent = department.IsParent,
                ParentDepartmentID = department.ParentDepartmentID,
                RestaurantId = department.RestaurantId
            };
        }

        internal static RestaurantMenuNormModel FromDataTransferObject(RestaurantMenuNorm restaurantMenuNorm, RestaurantMenuNormDetail[] restaurantMenuNormDetails)
        {
            if (restaurantMenuNorm != null)
            {
                return new RestaurantMenuNormModel
                {
                    MenuNormID = restaurantMenuNorm.MenuNormID,
                    MenuNormCode = restaurantMenuNorm.MenuNormCode,
                    MenuNormName = restaurantMenuNorm.MenuNormName,
                    RestaurantID = restaurantMenuNorm.RestaurantID,
                    Description = restaurantMenuNorm.Description,
                    MenuID = restaurantMenuNorm.MenuID,
                    RestaurantMenuNormDetails = Mapper.FromDataTransferObjects(restaurantMenuNormDetails)
                };
            }
            else
            {
                return new RestaurantMenuNormModel
                {
                    RestaurantMenuNormDetails = Mapper.FromDataTransferObjects(restaurantMenuNormDetails)
                };
            }
        }

        internal static RestaurantMenuModel FromDataTransferObject(RestaurantMenu restaurantMenu)
        {
            return new RestaurantMenuModel
            {
                MenuID = restaurantMenu.MenuID,
                MenuCode = restaurantMenu.MenuCode,
                MenuName = restaurantMenu.MenuName,
                Description = restaurantMenu.Description,
                UnitID = restaurantMenu.UnitID,
                SalesPrice = restaurantMenu.SalesPrice,
                MenuImage = restaurantMenu.MenuImage,
                IsActive = restaurantMenu.IsActive,
                IsNorm = restaurantMenu.IsNorm,
                RestaurantID = restaurantMenu.RestaurantID,
                MenuCategoryID = restaurantMenu.MenuCategoryID,
            };
        }

        internal static InwardOutwardModel FromDataTransferObject(InwardOutward inwardOutward, InwardOutwardDetail[] inwardOutwardDetails)
        {
            if (inwardOutward != null)
            {
                return new InwardOutwardModel
                {
                    RefID = inwardOutward.RefID,
                    RefType = inwardOutward.RefType,
                    RefDate = inwardOutward.RefDate,
                    PostedDate = inwardOutward.PostedDate,
                    RefNo = inwardOutward.RefNo,
                    EmployeeID = inwardOutward.EmployeeID,
                    AccountingObjectID = inwardOutward.AccountingObjectID,
                    AccountingObjectName = inwardOutward.AccountingObjectName,
                    AccountingObjectAddress = inwardOutward.AccountingObjectAddress,
                    JournalMemo = inwardOutward.JournalMemo,
                    CurrencyID = inwardOutward.CurrencyID,
                    ExchangeRate = inwardOutward.ExchangeRate,
                    IsImportPurchase = inwardOutward.IsImportPurchase,
                    ShippingMethodID = inwardOutward.ShippingMethodID,
                    TotalAmount = inwardOutward.TotalAmount,
                    RestaurantID = inwardOutward.RestaurantID,
                    IsPosted = inwardOutward.IsPosted,
                    IsMaterial = inwardOutward.IsMaterial,
                    InwardOutwardDetails = Mapper.FromDataTransferObjects(inwardOutwardDetails)
                };
            }
            else
            {
                return new InwardOutwardModel
                {
                    InwardOutwardDetails = Mapper.FromDataTransferObjects(inwardOutwardDetails)
                };
            }
        }

        internal static UnitModel FromDataTransferObject(Units unit)
        {
            return new UnitModel
            {
                UnitID = unit.UnitID,
                UnitCode = unit.UnitCode,
                UnitName = unit.UnitName,
                RestaurantID = unit.RestaurantID,
                Description = unit.Description,
                IsActive = unit.IsActive
            };
        }

        internal static StockModel FromDataTransferObject(Stock restaurantMenuNorm)
        {
            return new StockModel
            {
                StockID = restaurantMenuNorm.StockID,
                StockCode = restaurantMenuNorm.StockCode,
                StockName = restaurantMenuNorm.StockName,
                RestaurantID = restaurantMenuNorm.RestaurantID,
                Description = restaurantMenuNorm.Description,
                IsActive = restaurantMenuNorm.IsActive
            };
        }

        internal static RestaurantAreaModel FromDataTransferObject(RestaurantArea restaurantArea)
        {
            return new RestaurantAreaModel
            {
                RestaurantAreaID = restaurantArea.RestaurantAreaID,
                RestaurantAreaCode = restaurantArea.RestaurantAreaCode,
                RestaurantAreaName = restaurantArea.RestaurantAreaName,
                RestaurantID = restaurantArea.RestaurantID,
                Description = restaurantArea.Description,
                IsActive = restaurantArea.IsActive
            };
        }

        internal static RestaurantMenuNormDetailModel FromDataTransferObject(RestaurantMenuNormDetail restaurantMenuNormDetail)
        {
            return new RestaurantMenuNormDetailModel
            {
                MenuNormDetailID = restaurantMenuNormDetail.MenuNormDetailID,
                MenuNormID = restaurantMenuNormDetail.MenuNormID,
                InventoryItemID = restaurantMenuNormDetail.InventoryItemID,
                InventoryItemName = restaurantMenuNormDetail.InventoryItemName,
                UnitID = restaurantMenuNormDetail.UnitID,
                UnitPrice = restaurantMenuNormDetail.UnitPrice,
                RestaurantID = restaurantMenuNormDetail.RestaurantID,
                Quantity = restaurantMenuNormDetail.Quantity,
            };
        }

        internal static InwardOutwardDetailModel FromDataTransferObject(InwardOutwardDetail inwardOutwardDetail)
        {
            return new InwardOutwardDetailModel
            {
                RefDetailID = inwardOutwardDetail.RefDetailID,
                RefID = inwardOutwardDetail.RefID,
                RestaurantMenuID = inwardOutwardDetail.RestaurantMenuID,
                InventoryItemID = inwardOutwardDetail.InventoryItemID,
                InventoryItemName = inwardOutwardDetail.InventoryItemName,
                Description = inwardOutwardDetail.Description,
                StockID = inwardOutwardDetail.StockID,
                UnitID = inwardOutwardDetail.UnitID,
                UnitConvertID = inwardOutwardDetail.UnitConvertID,
                Quantity = inwardOutwardDetail.Quantity,
                QuantityConvert = inwardOutwardDetail.QuantityConvert,
                UnitPrice = inwardOutwardDetail.UnitPrice,
                UnitPriceConvert = inwardOutwardDetail.UnitPriceConvert,
                Amount = inwardOutwardDetail.Amount,
                AmountConvert = inwardOutwardDetail.AmountConvert,
                OutwardPurpose = inwardOutwardDetail.OutwardPurpose,
            };
        }

        internal static RestaurantTableModel FromDataTransferObject(RestaurantTable restaurantTable)
        {
            return new RestaurantTableModel
            {
                RestaurantTableID = restaurantTable.RestaurantTableID,
                RestaurantTableCode = restaurantTable.RestaurantTableCode,
                RestaurantTableName = restaurantTable.RestaurantTableName,
                RestaurantID = restaurantTable.RestaurantID,
                RestaurantAreaID = restaurantTable.RestaurantAreaID,
                MaxPeople = restaurantTable.MaxPeople,
                IsOrder = restaurantTable.IsOrder,
                IsOrderOnline = restaurantTable.IsOrderOnline,
                Description = restaurantTable.Description,
                IsActive = restaurantTable.IsActive
            };
        }

        internal static InventoryItemModel FromDataTransferObject(InventoryItem inventoryItem)
        {
            return new InventoryItemModel
            {
                InventoryItemID = inventoryItem.InventoryItemID,
                InventoryCategoryID = inventoryItem.InventoryCategoryID,
                InventoryItemCode = inventoryItem.InventoryItemCode,
                InventoryItemName = inventoryItem.InventoryItemName,
                UnitID = inventoryItem.UnitID,
                UnitPrice = inventoryItem.UnitPrice,
                SalesPrice = inventoryItem.SalesPrice,
                StockID = inventoryItem.StockID,
                MinimumStock = inventoryItem.MinimumStock,
                IsActive = inventoryItem.IsActive,
                Description = inventoryItem.Description,
                RestaurantId = inventoryItem.RestaurantId,
                IsMaterial = inventoryItem.IsMaterial
            };
        }

        internal static ProvinceModel FromDataTransferObject(Province province)
        {
            return new ProvinceModel
            {
                ProvinceCode = province.ProvinceCode,
                ProvinceName = province.ProvinceName,
                CreateDate = province.CreateDate,
                ModifiedDate = province.ModifiedDate,
                Description = province.Description,
                IsActive = province.IsActive
            };
        }

        internal static AccountingObjectModel FromDataTransferObject(AccountingObject accountingObject)
        {
            return new AccountingObjectModel
            {
                AccountingObjectID = accountingObject.AccountingObjectID,
                AccountingObjectCode = accountingObject.AccountingObjectCode,
                AccountingObjectName = accountingObject.AccountingObjectName,
                AccountingObjectCategoryId = accountingObject.AccountingObjectCategoryId,
                RestaurantId = accountingObject.RestaurantId,
                Prefix = accountingObject.Prefix,
                Address = accountingObject.Address,
                Fax = accountingObject.Fax,
                EmailAddress = accountingObject.EmailAddress,
                Website = accountingObject.Website,
                Tel = accountingObject.Tel,
                CompanyTaxCode = accountingObject.CompanyTaxCode,
                BirthDate = accountingObject.BirthDate,
                FiredDate = accountingObject.FiredDate,
                Description = accountingObject.Description,
                ContactName = accountingObject.ContactName,
                JobCandidateName = accountingObject.JobCandidateName,
                ContactSex = accountingObject.ContactSex,
                ContactMobile = accountingObject.ContactMobile,
                ContactEmail = accountingObject.ContactEmail,
                ContactHomeTel = accountingObject.ContactHomeTel,
                ContactAddress = accountingObject.ContactAddress,
                IsPersonal = accountingObject.IsPersonal,
                IdentificationNumber = accountingObject.IdentificationNumber,
                IssueDate = accountingObject.IssueDate,
                IssueBy = accountingObject.IssueBy,
                IsVendor = accountingObject.IsVendor,
                IsCustomer = accountingObject.IsCustomer,
                IsEmployess = accountingObject.IsEmployess,
                CountryRegion = accountingObject.CountryRegion,
                Province = accountingObject.Province,
                District = accountingObject.District,
                Village = accountingObject.Village,
                IsActive = accountingObject.IsActive,
                DepartmentID = accountingObject.DepartmentID
            };
        }

        internal static UserGroup ToDataTransferObject(UserGroupModel userGroup)
        {
            return new UserGroup
            {
                UserGroupID = userGroup.UserGroupID,
                UserGroupName = userGroup.UserGroupName,
                Image = userGroup.Image,
                RestaurantID = userGroup.RestaurantID,
                CreateBy = userGroup.CreateBy,
                CreateDate = userGroup.CreateDate,
                ModifiedBy = userGroup.ModifiedBy,
                ModifiedDate = userGroup.ModifiedDate,
                Description = userGroup.Description,
                IsActive = userGroup.IsActive
            };
        }

        internal static InwardOutward ToDataTransferObject(InwardOutwardModel inwardOutward)
        {
            return new InwardOutward
            {
                RefID = inwardOutward.RefID,
                RefType = inwardOutward.RefType,
                RefDate = inwardOutward.RefDate,
                PostedDate = inwardOutward.PostedDate,
                RefNo = inwardOutward.RefNo,
                EmployeeID = inwardOutward.EmployeeID,
                AccountingObjectID = inwardOutward.AccountingObjectID,
                AccountingObjectName = inwardOutward.AccountingObjectName,
                AccountingObjectAddress = inwardOutward.AccountingObjectAddress,
                JournalMemo = inwardOutward.JournalMemo,
                CurrencyID = inwardOutward.CurrencyID,
                ExchangeRate = inwardOutward.ExchangeRate,
                IsImportPurchase = inwardOutward.IsImportPurchase,
                ShippingMethodID = inwardOutward.ShippingMethodID,
                TotalAmount = inwardOutward.TotalAmount,
                RestaurantID = inwardOutward.RestaurantID,
                IsPosted = inwardOutward.IsPosted,
                IsMaterial = inwardOutward.IsMaterial
            };
        }

        internal static AutoID ToDataTransferObject(AutoIDModel autoId)
        {
            return new AutoID
            {
                AutoId = autoId.AutoId,
                RefTypeID = autoId.RefTypeID,
                RefTypeName = autoId.RefTypeName,
                Prefix = autoId.Prefix,
                Value = autoId.Value,
                LengthOfValue = autoId.LengthOfValue,
                Suffix = autoId.Suffix,
                RestaurantID = autoId.RestaurantID,
            };
        }

        internal static Department ToDataTransferObject(DepartmentModel department)
        {
            return new Department
            {
                DepartmentID = department.DepartmentID,
                DepartmentCode = department.DepartmentCode,
                DepartmentName = department.DepartmentName,
                Description = department.Description,
                IsActive = department.IsActive,
                IsParent = department.IsParent,
                ParentDepartmentID = department.ParentDepartmentID,
                RestaurantId = department.RestaurantId
            };
        }

        internal static RestaurantArea ToDataTransferObject(RestaurantAreaModel restaurantArea)
        {
            return new RestaurantArea
            {
                RestaurantAreaID = restaurantArea.RestaurantAreaID,
                RestaurantAreaCode = restaurantArea.RestaurantAreaCode,
                RestaurantAreaName = restaurantArea.RestaurantAreaName,
                RestaurantID = restaurantArea.RestaurantID,
                Description = restaurantArea.Description,
                IsActive = restaurantArea.IsActive
            };
        }

        internal static RestaurantTable ToDataTransferObject(RestaurantTableModel restaurantTable)
        {
            return new RestaurantTable
            {
                RestaurantTableID = restaurantTable.RestaurantTableID,
                RestaurantTableCode = restaurantTable.RestaurantTableCode,
                RestaurantTableName = restaurantTable.RestaurantTableName,
                RestaurantID = restaurantTable.RestaurantID,
                RestaurantAreaID = restaurantTable.RestaurantAreaID,
                MaxPeople = restaurantTable.MaxPeople,
                IsOrder = restaurantTable.IsOrder,
                IsOrderOnline = restaurantTable.IsOrderOnline,
                Description = restaurantTable.Description,
                IsActive = restaurantTable.IsActive
            };
        }

        internal static RestaurantMenu ToDataTransferObject(RestaurantMenuModel restaurantMenu)
        {
            return new RestaurantMenu
            {
                MenuID = restaurantMenu.MenuID,
                MenuCode = restaurantMenu.MenuCode,
                MenuName = restaurantMenu.MenuName,
                Description = restaurantMenu.Description,
                UnitID = restaurantMenu.UnitID,
                SalesPrice = restaurantMenu.SalesPrice,
                MenuImage = restaurantMenu.MenuImage,
                IsActive = restaurantMenu.IsActive,
                IsNorm = restaurantMenu.IsNorm,
                RestaurantID = restaurantMenu.RestaurantID,
                MenuCategoryID = restaurantMenu.MenuCategoryID
            };
        }

        internal static CountryRegion ToDataTransferObject(CountryRegionModel countryRegion)
        {
            return new CountryRegion
            {
                CountryRegionCode = countryRegion.CountryRegionCode,
                CountryRegionName = countryRegion.CountryRegionName,
                CreateDate = countryRegion.CreateDate,
                ModifiedDate = countryRegion.ModifiedDate,
                Description = countryRegion.Description,
                IsActive = countryRegion.IsActive
            };
        }

        internal static Currency ToDataTransferObject(CurrencyModel currency)
        {
            return new Currency
            {
                CurrencyID = currency.CurrencyID,
                CurrencyCode = currency.CurrencyCode,
                CurrencyName = currency.CurrencyName,
                Description = currency.Description,
                IsActive = currency.IsActive
            };
        }

        internal static ShipMethod ToDataTransferObject(ShipMethodModel shipMethod)
        {
            return new ShipMethod
            {
                ShipMethodID = shipMethod.ShipMethodID,
                ShipCode = shipMethod.ShipCode,
                ShipName = shipMethod.ShipName,
                Description = shipMethod.Description,
                IsActive = shipMethod.IsActive
            };
        }

        internal static RestaurantMenuCategory ToDataTransferObject(RestaurantMenuCategoryModel restaurantMenuCategory)
        {
            return new RestaurantMenuCategory
            {
                MenuCategoryID = restaurantMenuCategory.MenuCategoryID,
                MenuCategoryCode = restaurantMenuCategory.MenuCategoryCode,
                MenuCategoryName = restaurantMenuCategory.MenuCategoryName,
                RestaurantID = restaurantMenuCategory.RestaurantID,
                IsParent = restaurantMenuCategory.IsParent,
                ParentID = restaurantMenuCategory.ParentID,
                Description = restaurantMenuCategory.Description,
                IsActive = restaurantMenuCategory.IsActive
            };
        }

        internal static District ToDataTransferObject(DistrictModel district)
        {
            return new District
            {
                DistrictCode = district.DistrictCode,
                DistrictName = district.DistrictName,
                CreateDate = district.CreateDate,
                ModifiedDate = district.ModifiedDate,
                Description = district.Description,
                IsActive = district.IsActive
            };
        }

        internal static Restaurant ToDataTransferObject(RestaurantModel restaurant)
        {
            return new Restaurant
            {
                RestaurantID = restaurant.RestaurantID,
                RestaurantCode = restaurant.RestaurantCode,
                RestaurantName = restaurant.RestaurantName,
                Address = restaurant.Address,
                PhoneNumber = restaurant.PhoneNumber,
                Fax = restaurant.Fax,
                Email = restaurant.Email,
                Website = restaurant.Website,
                TaxCode = restaurant.TaxCode,
                IsActive = restaurant.IsActive,
                IsAgencies = restaurant.IsAgencies,
                Description = restaurant.Description
            };
        }

        internal static InventoryItem ToDataTransferObject(InventoryItemModel inventoryItem)
        {
            return new InventoryItem
            {
                InventoryItemID = inventoryItem.InventoryItemID,
                InventoryCategoryID = inventoryItem.InventoryCategoryID,
                InventoryItemCode = inventoryItem.InventoryItemCode,
                InventoryItemName = inventoryItem.InventoryItemName,
                UnitID = inventoryItem.UnitID,
                UnitPrice = inventoryItem.UnitPrice,
                SalesPrice = inventoryItem.SalesPrice,
                StockID = inventoryItem.StockID,
                MinimumStock = inventoryItem.MinimumStock,
                IsActive = inventoryItem.IsActive,
                Description = inventoryItem.Description,
                RestaurantId = inventoryItem.RestaurantId,
                IsMaterial = inventoryItem.IsMaterial
            };
        }

        internal static Units ToDataTransferObject(UnitModel unit)
        {
            return new Units
            {
                UnitID = unit.UnitID,
                UnitCode = unit.UnitCode,
                UnitName = unit.UnitName,
                RestaurantID = unit.RestaurantID,
                Description = unit.Description,
                IsActive = unit.IsActive
            };
        }

        internal static Province ToDataTransferObject(ProvinceModel Province)
        {
            return new Province
            {
                ProvinceCode = Province.ProvinceCode,
                ProvinceName = Province.ProvinceName,
                CreateDate = Province.CreateDate,
                ModifiedDate = Province.ModifiedDate,
                Description = Province.Description,
                IsActive = Province.IsActive
            };
        }

        internal static Stock ToDataTransferObject(StockModel restaurantMenuNorm)
        {
            return new Stock
            {
                StockID = restaurantMenuNorm.StockID,
                StockCode = restaurantMenuNorm.StockCode,
                StockName = restaurantMenuNorm.StockName,
                RestaurantID = restaurantMenuNorm.RestaurantID,
                Description = restaurantMenuNorm.Description,
                IsActive = restaurantMenuNorm.IsActive
            };
        }

        internal static TimeSheetSign ToDataTransferObject(TimeSheetSignModel timeSheetSign)
        {
            return new TimeSheetSign
            {
                TimeSheetSignID = timeSheetSign.TimeSheetSignID,
                TimeSheetSignCode = timeSheetSign.TimeSheetSignCode,
                TimeSheetSignName = timeSheetSign.TimeSheetSignName,
                SalaryRate = timeSheetSign.SalaryRate,
                Description = timeSheetSign.Description,
                IsActive = timeSheetSign.IsActive
            };
        }

        internal static RestaurantMenuNorm ToDataTransferObject(RestaurantMenuNormModel restaurantMenuNorm)
        {
            return new RestaurantMenuNorm
            {
                MenuNormID = restaurantMenuNorm.MenuNormID,
                MenuNormCode = restaurantMenuNorm.MenuNormCode,
                MenuNormName = restaurantMenuNorm.MenuNormName,
                RestaurantID = restaurantMenuNorm.RestaurantID,
                Description = restaurantMenuNorm.Description,
                MenuID = restaurantMenuNorm.MenuID
            };
        }

        internal static AccountingObject ToDataTransferObject(AccountingObjectModel accountingObject)
        {
            return new AccountingObject
            {
                AccountingObjectID = accountingObject.AccountingObjectID,
                AccountingObjectCode = accountingObject.AccountingObjectCode,
                AccountingObjectName = accountingObject.AccountingObjectName,
                AccountingObjectCategoryId = accountingObject.AccountingObjectCategoryId,
                RestaurantId = accountingObject.RestaurantId,
                Prefix = accountingObject.Prefix,
                Address = accountingObject.Address,
                Fax = accountingObject.Fax,
                Tel = accountingObject.Tel,
                EmailAddress = accountingObject.EmailAddress,
                Website = accountingObject.Website,
                CompanyTaxCode = accountingObject.CompanyTaxCode,
                BirthDate = accountingObject.BirthDate,
                FiredDate = accountingObject.FiredDate,
                Description = accountingObject.Description,
                ContactName = accountingObject.ContactName,
                JobCandidateName = accountingObject.JobCandidateName,
                ContactSex = accountingObject.ContactSex,
                ContactMobile = accountingObject.ContactMobile,
                ContactEmail = accountingObject.ContactEmail,
                ContactHomeTel = accountingObject.ContactHomeTel,
                ContactAddress = accountingObject.ContactAddress,
                IsPersonal = accountingObject.IsPersonal,
                IdentificationNumber = accountingObject.IdentificationNumber,
                IssueDate = accountingObject.IssueDate,
                IssueBy = accountingObject.IssueBy,
                IsVendor = accountingObject.IsVendor,
                IsCustomer = accountingObject.IsCustomer,
                IsEmployess = accountingObject.IsEmployess,
                CountryRegion = accountingObject.CountryRegion,
                Province = accountingObject.Province,
                District = accountingObject.District,
                Village = accountingObject.Village,
                IsActive = accountingObject.IsActive,
                DepartmentID = accountingObject.DepartmentID
            };
        }

        internal static AccountingObjectCategory ToDataTransferObject(AccountingObjectCategoryModel accountingObjectCategory)
        {
            return new AccountingObjectCategory
            {
                AccountingObjectCategoryID = accountingObjectCategory.AccountingObjectCategoryID,
                AccountingObjectCategoryCode = accountingObjectCategory.AccountingObjectCategoryCode,
                AccountingObjectCategoryName = accountingObjectCategory.AccountingObjectCategoryName,
                ParentID = accountingObjectCategory.ParentID,
                IsParent = accountingObjectCategory.IsParent,
                IsCustomer = accountingObjectCategory.IsCustomer,
                IsVendor = accountingObjectCategory.IsVendor,
                IsEmployee = accountingObjectCategory.IsEmployee,
                RestaurantID = accountingObjectCategory.RestaurantID,
                Description = accountingObjectCategory.Description,
                IsActive = accountingObjectCategory.IsActive
            };
        }

        internal static InventoryItemCategory ToDataTransferObject(InventoryItemCategoryModel inventoryItemCategory)
        {
            return new InventoryItemCategory
            {
                InventoryCategoryID = inventoryItemCategory.InventoryCategoryID,
                InventoryCategoryCode = inventoryItemCategory.InventoryCategoryCode,
                InventoryCategoryName = inventoryItemCategory.InventoryCategoryName,
                ParentID = inventoryItemCategory.ParentID,
                IsParent = inventoryItemCategory.IsParent,
                IsMaterial = inventoryItemCategory.IsMaterial,
                RestaurantID = inventoryItemCategory.RestaurantID,
                Description = inventoryItemCategory.Description,
                IsActive = inventoryItemCategory.IsActive
            };
        }

        internal static RestaurantMenuNormDetail ToDataTransferObject(RestaurantMenuNormDetailModel restaurantMenuNormDetail)
        {
            return new RestaurantMenuNormDetail
            {
                MenuNormDetailID = restaurantMenuNormDetail.MenuNormDetailID,
                MenuNormID = restaurantMenuNormDetail.MenuNormID,
                InventoryItemID = restaurantMenuNormDetail.InventoryItemID,
                InventoryItemName = restaurantMenuNormDetail.InventoryItemName,
                UnitID = restaurantMenuNormDetail.UnitID,
                UnitPrice = restaurantMenuNormDetail.UnitPrice,
                RestaurantID = restaurantMenuNormDetail.RestaurantID,
                Quantity = restaurantMenuNormDetail.Quantity,
            };
        }

        internal static IList<AccountingObjectCategoryModel> FromDataTransferObjects(AccountingObjectCategory[] accountingObjectCategories)
        {
            if (accountingObjectCategories == null)
                return null;

            return accountingObjectCategories.Select(c => FromDataTransferObject(c)).ToList();
        }

        internal static IList<CountryRegionModel> FromDataTransferObjects(CountryRegion[] countryRegions)
        {
            if (countryRegions == null)
                return null;

            return countryRegions.Select(c => FromDataTransferObject(c)).ToList();
        }

        internal static IList<DistrictModel> FromDataTransferObjects(District[] districts)
        {
            if (districts == null)
                return null;

            return districts.Select(c => FromDataTransferObject(c)).ToList();
        }

        internal static IList<ShipMethodModel> FromDataTransferObjects(ShipMethod[] shipMethods)
        {
            if (shipMethods == null)
                return null;

            return shipMethods.Select(c => FromDataTransferObject(c)).ToList();
        }

        internal static IList<ProvinceModel> FromDataTransferObjects(Province[] provinces)
        {
            if (provinces == null)
                return null;

            return provinces.Select(c => FromDataTransferObject(c)).ToList();
        }

        internal static IList<StockModel> FromDataTransferObjects(Stock[] restaurantMenuNorms)
        {
            if (restaurantMenuNorms == null)
                return null;

            return restaurantMenuNorms.Select(c => FromDataTransferObject(c)).ToList();
        }

        internal static IList<DepartmentModel> FromDataTransferObjects(Department[] departments)
        {
            if (departments == null)
                return null;

            return departments.Select(c => FromDataTransferObject(c)).ToList();
        }

        internal static IList<InwardOutwardModel> FromDataTransferObjects(InwardOutward[] inwardOutwards)
        {
            if (inwardOutwards == null)
                return null;

            return inwardOutwards.Select(c => FromDataTransferObject(c, null)).ToList();
        }

        internal static IList<RestaurantAreaModel> FromDataTransferObjects(RestaurantArea[] restaurantAreas)
        {
            if (restaurantAreas == null)
                return null;

            return restaurantAreas.Select(c => FromDataTransferObject(c)).ToList();
        }

        internal static IList<RestaurantMenuNormDetailModel> FromDataTransferObjects(RestaurantMenuNormDetail[] restaurantMenuNormDetails)
        {
            if (restaurantMenuNormDetails == null)
                return null;

            return restaurantMenuNormDetails.Select(c => FromDataTransferObject(c)).ToList();
        }

        internal static IList<InwardOutwardDetailModel> FromDataTransferObjects(InwardOutwardDetail[] inwardOutwardDetails)
        {
            if (inwardOutwardDetails == null)
                return null;

            return inwardOutwardDetails.Select(c => FromDataTransferObject(c)).ToList();
        }

        internal static IList<RestaurantTableModel> FromDataTransferObjects(RestaurantTable[] restaurantTable)
        {
            if (restaurantTable == null)
                return null;

            return restaurantTable.Select(c => FromDataTransferObject(c)).ToList();
        }

        internal static IList<UserGroupModel> FromDataTransferObjects(UserGroup[] userGroups)
        {
            if (userGroups == null)
                return null;

            return userGroups.Select(c => FromDataTransferObject(c)).ToList();
        }

        internal static IList<RestaurantModel> FromDataTransferObjects(Restaurant[] restaurants)
        {
            if (restaurants == null)
                return null;

            return restaurants.Select(c => FromDataTransferObject(c)).ToList();
        }

        internal static IList<AccountingObjectModel> FromDataTransferObjects(AccountingObject[] accountingObjects)
        {
            if (accountingObjects == null)
                return null;

            return accountingObjects.Select(c => FromDataTransferObject(c)).ToList();
        }

        internal static IList<InventoryItemCategoryModel> FromDataTransferObjects(InventoryItemCategory[] inventoryItemCategories)
        {
            if (inventoryItemCategories == null)
                return null;

            return inventoryItemCategories.Select(c => FromDataTransferObject(c)).ToList();
        }

        internal static IList<UnitModel> FromDataTransferObjects(Units[] units)
        {
            if (units == null)
                return null;

            return units.Select(c => FromDataTransferObject(c)).ToList();
        }

        internal static IList<RestaurantMenuModel> FromDataTransferObjects(RestaurantMenu[] restaurantMenus)
        {
            if (restaurantMenus == null)
                return null;

            return restaurantMenus.Select(c => FromDataTransferObject(c)).ToList();
        }

        internal static IList<InventoryItemModel> FromDataTransferObjects(InventoryItem[] inventoryItems)
        {
            if (inventoryItems == null)
                return null;

            return inventoryItems.Select(c => FromDataTransferObject(c)).ToList();
        }

        internal static IList<TimeSheetSignModel> FromDataTransferObjects(TimeSheetSign[] timeSheetSigns)
        {
            if (timeSheetSigns == null)
                return null;

            return timeSheetSigns.Select(c => FromDataTransferObject(c)).ToList();
        }

        internal static IList<RestaurantMenuCategoryModel> FromDataTransferObjects(RestaurantMenuCategory[] restaurantMenuCategories)
        {
            if (restaurantMenuCategories == null)
                return null;

            return restaurantMenuCategories.Select(c => FromDataTransferObject(c)).ToList();
        }

        internal static IList<RestaurantMenuNormModel> FromDataTransferObjects(RestaurantMenuNorm[] restaurantMenuNorms)
        {
            if (restaurantMenuNorms == null)
                return null;

            return restaurantMenuNorms.Select(c => FromDataTransferObject(c, null)).ToList();
        }

        internal static RestaurantMenuNormDetail[] FromDataTransferObjects(IList<RestaurantMenuNormDetailModel> restaurantMenuNormDetailModels)
        {
            RestaurantMenuNormDetail[] restaurantMenuNormDetails = new RestaurantMenuNormDetail[restaurantMenuNormDetailModels.Count];
            int i = 0;

            foreach (var item in restaurantMenuNormDetailModels)
            {
                restaurantMenuNormDetails[i] = new RestaurantMenuNormDetail
                {
                    MenuNormDetailID = item.MenuNormDetailID,
                    MenuNormID = item.MenuNormID,
                    InventoryItemID = item.InventoryItemID,
                    InventoryItemName = item.InventoryItemName,
                    UnitID = item.UnitID,
                    UnitPrice = item.UnitPrice,
                    RestaurantID = item.RestaurantID,
                    Quantity = item.Quantity,
                };
                i++;
            }

            return restaurantMenuNormDetails;
        }

        internal static InwardOutwardDetail[] ToDataTransferObjects(IList<InwardOutwardDetailModel> inwardOutwardDetailModels)
        {
            InwardOutwardDetail[] inwardOutwardDetails = new InwardOutwardDetail[inwardOutwardDetailModels.Count];
            int i = 0;

            foreach (var inwardOutwardDetail in inwardOutwardDetailModels)
            {
                inwardOutwardDetails[i] = new InwardOutwardDetail
                {
                    RefDetailID = inwardOutwardDetail.RefDetailID,
                    RefID = inwardOutwardDetail.RefID,
                    RestaurantMenuID = inwardOutwardDetail.RestaurantMenuID,
                    InventoryItemID = inwardOutwardDetail.InventoryItemID,
                    InventoryItemName = inwardOutwardDetail.InventoryItemName,
                    Description = inwardOutwardDetail.Description,
                    StockID = inwardOutwardDetail.StockID,
                    UnitID = inwardOutwardDetail.UnitID,
                    UnitConvertID = inwardOutwardDetail.UnitConvertID,
                    Quantity = inwardOutwardDetail.Quantity,
                    QuantityConvert = inwardOutwardDetail.QuantityConvert,
                    UnitPrice = inwardOutwardDetail.UnitPrice,
                    UnitPriceConvert = inwardOutwardDetail.UnitPriceConvert,
                    Amount = inwardOutwardDetail.Amount,
                    AmountConvert = inwardOutwardDetail.AmountConvert,
                    OutwardPurpose = inwardOutwardDetail.OutwardPurpose,
                };
                i++;
            }

            return inwardOutwardDetails;
        }

        internal static InventoryLedger[] ToDataTransferObjects(IList<InventoryLedgerModel> inventoryLedgerModels)
        {
            InventoryLedger[] inventoryLedgers = new InventoryLedger[inventoryLedgerModels.Count];
            int i = 0;

            foreach (var inventoryLedger in inventoryLedgerModels)
            {
                inventoryLedgers[i] = new InventoryLedger
                {
                    InventoryLedgerID = inventoryLedger.InventoryLedgerID,
                    RefID = inventoryLedger.RefID,
                    RefType = inventoryLedger.RefType,
                    RefDate = inventoryLedger.RefDate,
                    PostedDate = inventoryLedger.PostedDate,
                    RefNo = inventoryLedger.RefNo,
                    RefDetailID = inventoryLedger.RefDetailID,
                    StockID = inventoryLedger.StockID,
                    InventoryItemID = inventoryLedger.InventoryItemID,
                    RestaurantMenuID = inventoryLedger.RestaurantMenuID,
                    Unit = inventoryLedger.Unit,
                    UnitPrice = inventoryLedger.UnitPrice,
                    InwardQuantity = inventoryLedger.InwardQuantity,
                    OutwardQuantity = inventoryLedger.OutwardQuantity,
                    InwardAmount = inventoryLedger.InwardAmount,
                    OutwardAmount = inventoryLedger.OutwardAmount,
                    JournalMemo = inventoryLedger.JournalMemo,
                    Description = inventoryLedger.Description,
                    OutwardPurpose = inventoryLedger.OutwardPurpose,
                    RestaurantID = inventoryLedger.RestaurantID
                };
                i++;
            }

            return inventoryLedgers;
        }

        internal static GeneralLedger[] ToDataTransferObjects(IList<GeneralLedgerModel> generalLedgerModels)
        {
            GeneralLedger[] generalLedgers = new GeneralLedger[generalLedgerModels.Count];
            int i = 0;

            foreach (var generalLedger in generalLedgerModels)
            {
                generalLedgers[i] = new GeneralLedger
                {
                    RefID = generalLedger.RefID,
                    RefDetailID = generalLedger.RefDetailID,
                    RefType = generalLedger.RefType,
                    RefDate = generalLedger.RefDate,
                    RefNo = generalLedger.RefNo,
                    PostedDate = generalLedger.PostedDate,
                    CurrencyID = generalLedger.CurrencyID,
                    AccountingObjectID = generalLedger.AccountingObjectID,
                    DescriptionMaster = generalLedger.DescriptionMaster,
                    DescriptionDetail = generalLedger.DescriptionDetail,
                    Amount = generalLedger.Amount,
                    RestaurantID = generalLedger.RestaurantID,
                };
                i++;
            }

            return generalLedgers;
        }

        internal static IList<CurrencyModel> FromDataTransferObjects(Currency[] currencies)
        {
            if (currencies == null)
                return null;

            return currencies.Select(c => FromDataTransferObject(c)).ToList();
        }
    }
}